var webside = {
	index : {
		initHomePage : function() {
			$(".page-content").load(sys.rootPath + "/welcome.jsp");
			$(".breadcrumb")
					.html(
							'<li><i class="ace-icon fa fa-home home-icon"></i><a href="javascript:webside.index.initHomePage();">首页</a></li><li class="active">控制台</li>');
		},
		menu : {
			initMenuEvent : function() {
				$("[nav-menu]")
						.each(
								function() {
									$(this)
											.bind(
													"click",
													function() {
														var nav = $(this).attr(
																"nav-menu");
														var sn = nav.split(",");
														// 清除用户信息菜单样式
														$(".user-menu")
																.find('li')
																.each(
																		function() {
																			$(
																					this)
																					.removeClass(
																							'active');
																		});
														// 处理监控-新窗口打开
														if (sn[sn.length - 1] == '/sirona'
																|| sn[sn.length - 1] == '/druid') {
															window
																	.open(sys.rootPath
																			+ sn[sn.length - 1]);
														} else {
															var breadcrumb = '<li><i class="ace-icon fa fa-home home-icon"></i><a href="javascript:webside.index.initHomePage();">首页</a></li>';
															for (var i = 0; i < sn.length - 1; i++) {
																breadcrumb += '<li class="active" onclick="back()"> '
																		+ sn[i]
																		+ '</li>';
															}
															// 设置面包屑内容
															$(".breadcrumb")
																	.html(
																			breadcrumb);
															// 加载页面
															$(".page-content")
																	.load(
																			sys.rootPath
																					+ sn[sn.length - 1]);
														}
														var level = $(this)
																.parent("li")
																.attr("level");
														if (level == 'level1'
																|| level == 'level2') {
															// 处理目录类型的点击事件-两级菜单
															$(this)
																	.parent(
																			"li")
																	.siblings()
																	.find(
																			"ul.nav-show")
																	.removeClass(
																			'nav-show')
																	.addClass(
																			'nav-hide')
																	.attr(
																			'style',
																			'display:none');
															// 处理菜单类型的点击事件
															$(this)
																	.parent()
																	.parent()
																	.parent(
																			"li")
																	.siblings()
																	.find(
																			"ul.nav-show")
																	.removeClass(
																			'nav-show')
																	.addClass(
																			'nav-hide')
																	.attr(
																			'style',
																			'display:none');
															$("ul.nav-list")
																	.find(
																			"li.active")
																	.removeClass(
																			"active")
																	.removeClass(
																			'open');
															$(this)
																	.parent()
																	.addClass(
																			"active")
																	.parent()
																	.parent(
																			"li")
																	.addClass(
																			'active open');
														} else if (level == 'level3') {
															// 处理目录类型的点击事件-三级菜单
															$(this)
																	.parent(
																			"li")
																	.siblings()
																	.find(
																			"ul.nav-show")
																	.removeClass(
																			'nav-show')
																	.addClass(
																			'nav-hide')
																	.attr(
																			'style',
																			'display:none');
															// 处理菜单类型的点击事件
															$(this)
																	.parent()
																	.parent()
																	.parent()
																	.parent()
																	.parent(
																			"li")
																	.siblings()
																	.find(
																			"ul.nav-show")
																	.removeClass(
																			'nav-show')
																	.addClass(
																			'nav-hide')
																	.attr(
																			'style',
																			'display:none');
															$("ul.nav-list")
																	.find(
																			"li.active")
																	.removeClass(
																			"active")
																	.removeClass(
																			'open');
															$(this)
																	.parent()
																	.addClass(
																			"active")
																	.parent()
																	.parent()
																	.parent()
																	.parent(
																			"li")
																	.addClass(
																			'active open');
														} else {
															// 处理目录类型的点击事件-四级菜单
															$(this)
																	.parent(
																			"li")
																	.siblings()
																	.find(
																			"ul.nav-show")
																	.removeClass(
																			'nav-show')
																	.addClass(
																			'nav-hide')
																	.attr(
																			'style',
																			'display:none');
															// 处理菜单类型的点击事件
															$(this)
																	.parent()
																	.parent()
																	.parent()
																	.parent()
																	.parent()
																	.parent()
																	.parent(
																			"li")
																	.siblings()
																	.find(
																			"ul.nav-show")
																	.removeClass(
																			'nav-show')
																	.addClass(
																			'nav-hide')
																	.attr(
																			'style',
																			'display:none');
															$("ul.nav-list")
																	.find(
																			"li.active")
																	.removeClass(
																			"active")
																	.removeClass(
																			'open');
															$(this)
																	.parent()
																	.addClass(
																			"active")
																	.parent()
																	.parent()
																	.parent()
																	.parent()
																	.parent()
																	.parent(
																			"li")
																	.addClass(
																			'active open');
														}
													});
								});
			},
			initDropdownMenuStyle : function() {
				$(".user-menu").find('li').each(function() {
					$(this).bind('click', function() {
						$(this).siblings().removeClass('active');
						$(this).addClass('active');
					});
				});
			}
		},
		initNavigation : function() {
			$("#ace-settings-navbar").click();
			$("#ace-settings-sidebar").click();
			// $("#ace-settings-breadcrumbs").click();
		},
		initScrollBar : function() {
			$("html").niceScroll({
				cursorborderradius : "5px",
				cursorwidth : 10
			});
		},
		/*
		 * 监听浏览器窗口大小变化
		 */
		resizeScrollBar : function() {
			$(window).resize(function() {
				$("html").getNiceScroll().resize();
			});
		}
	},
	common : {
		/**
		 * 加载非菜单展示页面
		 * 
		 * @param nav
		 *            待加载的资源URL
		 */
		loadPage : function(nav) {
			// 加载页面
			$(".page-content").load(sys.rootPath + nav);
		},
		/**
		 * 新增
		 * 
		 * @param {Object}
		 *            nav 提交url
		 */
		addModel : function(nav) {
			// 加载新增页面
			webside.common.loadPage(nav);
		},
		/**
		 * 编辑
		 * 
		 * @param {Object}
		 *            nav 提交url
		 */
		editModel : function(nav) {
			// 当前页码
			var nowPage = grid.pager.nowPage;
			// 获取每页显示的记录数(即: select框中的10,20,30)
			var pageSize = grid.pager.pageSize;
			// 获取排序字段
			var columnId = grid.sortParameter.columnId;
			// 获取排序方式 [0-不排序，1-正序，2-倒序]
			var sortType = grid.sortParameter.sortType;
			// 获取选择的行
			var rows = grid.getCheckedRecords();
			if (rows.length == 1) {
				if (nav.indexOf("?") > 0) {
					webside.common.loadPage(nav + '&id=' + rows[0].id
							+ "&page=" + nowPage + "&rows=" + pageSize
							+ "&sidx=" + columnId + "&sord=" + sortType);
				} else {
					webside.common.loadPage(nav + '?id=' + rows[0].id
							+ "&page=" + nowPage + "&rows=" + pageSize
							+ "&sidx=" + columnId + "&sord=" + sortType);
				}

			} else {
				layer.msg("你没有选择行或选择了多行数据", {
					icon : 0
				});
			}

		},
		/**
		 * 删除
		 * 
		 * @param {Object}
		 *            nav 提交url
		 * @param callback
		 *            主函数执行完毕后调用的回调函数名称
		 */
		delModel : function(nav, callback) {
			var rows = grid.getCheckedRecords();
			if (rows.length > 0) {
				if (nav == '/user/deleteBatch.html') {
					if (rows[0].role.name == '超级管理员') {
						layer.msg('该用户为超级管理员,不能删除!', {
							icon : 0
						});
						return false;
					}
				}
				if (nav == '/role/deleteBatch.html') {
					if (rows[0].name == '超级管理员') {
						layer.msg('该角色为基础角色,不能删除!', {
							icon : 0
						});
						return false;
					}
				}
				layer.confirm('确认删除吗？', {
					icon : 3,
					title : '删除提示'
				}, function(index, layero) {
					var delete_ids = [];
					/*
					 * $.each(rows, function(index, value) { ids.push(this.id);
					 * });
					 */
					for (var i = 0; i < rows.length; i++) {
						delete_ids.push(rows[i].id);
					}

					$.ajax({
						type : "POST",
						url : sys.rootPath + nav,
						data : {
							"ids" : delete_ids.join(',')
						},
						dataType : "json",
						success : function(resultdata) {
							if (resultdata.success) {
								layer.msg(resultdata.message, {
									icon : 1
								});
								if (callback) {
									callback();
								}
							} else {
								layer.msg(resultdata.message, {
									icon : 5
								});
							}
						},
						error : function(errorMsg) {
							layer.msg('服务器未响应,请稍后再试', {
								icon : 3
							});
						}
					});
					layer.close(index);
				});
			} else {
				layer.msg("你没有选择行或选择了多行数据", {
					icon : 0
				});
			}
		},
		/**
		 * 审核
		 * 
		 * @param {Object}
		 *            nav 提交url
		 * @param callback
		 *            主函数执行完毕后调用的回调函数名称
		 */
		chkModel : function(nav, callback) {
			var rows = grid.getCheckedRecords();
			if (rows.length > 0) {
				if (nav == '/user/deleteBatch.html') {
					if (rows[0].role.name == '超级管理员') {
						layer.msg('该用户为超级管理员,不能删除!', {
							icon : 0
						});
						return false;
					}
				}
				if (nav == '/role/deleteBatch.html') {
					if (rows[0].name == '超级管理员') {
						layer.msg('该角色为基础角色,不能删除!', {
							icon : 0
						});
						return false;
					}
				}
				layer.confirm('确认审核通过吗？', {
					icon : 3,
					title : '审核提示'
				}, function(index, layero) {
					var delete_ids = [];
					/*
					 * $.each(rows, function(index, value) { ids.push(this.id);
					 * });
					 */
					for (var i = 0; i < rows.length; i++) {
						delete_ids.push(rows[i].id);
					}

					$.ajax({
						type : "POST",
						url : sys.rootPath + nav,
						data : {
							"ids" : delete_ids.join(',')
						},
						dataType : "json",
						success : function(resultdata) {
							if (resultdata.success) {
								layer.msg(resultdata.message, {
									icon : 1
								});
								if (callback) {
									callback();
								}
							} else {
								layer.msg(resultdata.message, {
									icon : 5
								});
							}
						},
						error : function(errorMsg) {
							layer.msg('服务器未响应,请稍后再试', {
								icon : 3
							});
						}
					});
					layer.close(index);
				});
			} else {
				layer.msg("你没有选择行数据", {
					icon : 0
				});
			}
		},
		// 处理
		editDispose : function(nav, callback) {
			var rows = grid.getCheckedRecords();
			if (rows.length > 0) {
				if (nav == '/user/deleteBatch.html') {
					if (rows[0].role.name == '超级管理员') {
						layer.msg('该用户为超级管理员,不能删除!', {
							icon : 0
						});
						return false;
					}
				}
				if (nav == '/role/deleteBatch.html') {
					if (rows[0].name == '超级管理员') {
						layer.msg('该角色为基础角色,不能删除!', {
							icon : 0
						});
						return false;
					}
				}
				layer.confirm('确认处理吗？', {
					icon : 3,
					title : '处理提示'
				}, function(index, layero) {
					var delete_ids = [];
					for (var i = 0; i < rows.length; i++) {
						delete_ids.push(rows[i].id);
					}
					$.ajax({
						type : "POST",
						url : sys.rootPath + nav,
						data : {
							"ids" : delete_ids.join(',')
						},
						dataType : "json",
						success : function(resultdata) {
							if (resultdata.success) {
								layer.msg(resultdata.message, {
									icon : 1
								});
								if (callback) {
									callback();
								}
							} else {
								layer.msg(resultdata.message, {
									icon : 5
								});
							}
						},
						error : function(errorMsg) {
							layer.msg('服务器未响应,请稍后再试', {
								icon : 3
							});
						}
					});
					layer.close(index);
				});
			} else {
				layer.msg("你没有选择行或选择了多行数据", {
					icon : 0
				});
			}
		},
		// 上线
		editStatus : function(nav, callback) {
			var rows = grid.getCheckedRecords();
			if (rows.length > 0) {
				if (nav == '/user/deleteBatch.html') {
					if (rows[0].role.name == '超级管理员') {
						layer.msg('该用户为超级管理员,不能删除!', {
							icon : 0
						});
						return false;
					}
				}
				if (nav == '/role/deleteBatch.html') {
					if (rows[0].name == '超级管理员') {
						layer.msg('该角色为基础角色,不能删除!', {
							icon : 0
						});
						return false;
					}
				}
				layer.confirm('确认上线吗？', {
					icon : 3,
					title : '上线提示'
				}, function(index, layero) {
					var delete_ids = [];
					for (var i = 0; i < rows.length; i++) {
						delete_ids.push(rows[i].id);
					}
					$.ajax({
						type : "POST",
						url : sys.rootPath + nav,
						data : {
							"ids" : delete_ids.join(',')
						},
						dataType : "json",
						success : function(resultdata) {
							if (resultdata.success) {
								layer.msg(resultdata.message, {
									icon : 1
								});
								if (callback) {
									callback();
								}
							} else {
								layer.msg(resultdata.message, {
									icon : 5
								});
							}
						},
						error : function(errorMsg) {
							layer.msg('服务器未响应,请稍后再试', {
								icon : 3
							});
						}
					});
					layer.close(index);
				});
			} else {
				layer.msg("你没有选择行或选择了多行数据", {
					icon : 0
				});
			}
		},
		// 上线
		editStatus1 : function(nav, callback) {
			var rows = grid.getCheckedRecords();
			if (rows.length > 0) {
				if (nav == '/user/deleteBatch.html') {
					if (rows[0].role.name == '超级管理员') {
						layer.msg('该用户为超级管理员,不能删除!', {
							icon : 0
						});
						return false;
					}
				}
				if (nav == '/role/deleteBatch.html') {
					if (rows[0].name == '超级管理员') {
						layer.msg('该角色为基础角色,不能删除!', {
							icon : 0
						});
						return false;
					}
				}
				layer.confirm('确认下线吗？', {
					icon : 3,
					title : '下线提示'
				}, function(index, layero) {
					var delete_ids = [];
					/*
					 * $.each(rows, function(index, value) { ids.push(this.id);
					 * });
					 */
					for (var i = 0; i < rows.length; i++) {
						delete_ids.push(rows[i].id);
					}
					$.ajax({
						type : "POST",
						url : sys.rootPath + nav,
						data : {
							"ids" : delete_ids.join(',')
						},
						dataType : "json",
						success : function(resultdata) {
							if (resultdata.success) {
								layer.msg(resultdata.message, {
									icon : 1
								});
								if (callback) {
									callback();
								}
							} else {
								layer.msg(resultdata.message, {
									icon : 5
								});
							}
						},
						error : function(errorMsg) {
							layer.msg('服务器未响应,请稍后再试', {
								icon : 3
							});
						}
					});
					layer.close(index);
				});
			} else {
				layer.msg("你没有选择行或选择了多行数据", {
					icon : 0
				});
			}
		},
		unbindVideo : function(nav, callback) {
			var rows = grid.getCheckedRecords();
			if (rows.length > 0) {
				if (nav == '/user/deleteBatch.html') {
					if (rows[0].role.name == '超级管理员') {
						layer.msg('该用户为超级管理员,不能删除!', {
							icon : 0
						});
						return false;
					}
				}
				if (nav == '/role/deleteBatch.html') {
					if (rows[0].name == '超级管理员') {
						layer.msg('该角色为基础角色,不能删除!', {
							icon : 0
						});
						return false;
					}
				}
				layer.confirm('确认解除绑定吗？', {
					icon : 3,
					title : '解除提示'
				}, function(index, layero) {
					var delete_ids = [];
					/*
					 * $.each(rows, function(index, value) { ids.push(this.id);
					 * });
					 */
					for (var i = 0; i < rows.length; i++) {
						delete_ids.push(rows[i].id);
					}
					$.ajax({
						type : "POST",
						url : sys.rootPath + nav,
						data : {
							"ids" : delete_ids.join(',')
						},
						dataType : "json",
						success : function(resultdata) {
							if (resultdata.success) {
								layer.msg(resultdata.message, {
									icon : 1
								});
								if (callback) {
									callback();
								}
							} else {
								layer.msg(resultdata.message, {
									icon : 5
								});
							}
						},
						error : function(errorMsg) {
							layer.msg('服务器未响应,请稍后再试', {
								icon : 3
							});
						}
					});
					layer.close(index);
				});
			} else {
				layer.msg("你没有选择行或选择了多行数据", {
					icon : 0
				});
			}
		},
		/**
		 * 提交表单 适用场景：form表单的提交，主要用在用户、角色、资源等表单的添加、修改等
		 * 
		 * @param {Object}
		 *            commitUrl 表单提交地址
		 * @param {Object}
		 *            listUrl 表单提交成功后转向的列表页地址
		 */
		commit : function(formId, commitUrl, jumpUrl) {
			// 组装表单数据
			var index;
			var data = $("#" + formId).serialize();
			if (undefined != $("#pageNum").val()) {
				if (jumpUrl.indexOf("?") > 0) {
					jumpUrl = jumpUrl + '&page=' + $("#pageNum").val()
							+ '&rows=' + $("#pageSize").val() + '&sidx='
							+ $("#orderByColumn").val() + '&sord='
							+ $("#orderByType").val() + '&code='
							+ $("#positionCode").val();
				} else {
					jumpUrl = jumpUrl + '?page=' + $("#pageNum").val()
							+ '&rows=' + $("#pageSize").val() + '&sidx='
							+ $("#orderByColumn").val() + '&sord='
							+ $("#orderByType").val() + '&code='
							+ $("#positionCode").val();
				}
			} else {
				if (jumpUrl.indexOf("?") > 0) {
					jumpUrl = jumpUrl + '&code=' + $("#positionCode").val();
				} else {
					jumpUrl = jumpUrl + '?code=' + $("#positionCode").val();
				}
			}

			$.ajax({
				type : "POST",
				url : sys.rootPath + commitUrl,
				data : data,
				dataType : "json",
				beforeSend : function() {
					index = layer.load();
				},
				success : function(resultdata) {
					layer.close(index);
					if (resultdata.success) {
						layer.msg(resultdata.message, {
							icon : 1
						});
						webside.common.loadPage(jumpUrl);
					} else {
						layer.msg(resultdata.message, {
							icon : 5
						});
					}
				},
				error : function(data, errorMsg) {
					layer.close(index);
					layer.msg(data.responseText, {
						icon : 2
					});
				}
			});
		}
	},
	form : {
		user : {
			validateUserForm : function() {
				$('#userForm')
						.validate(
								{
									errorElement : 'div',
									errorClass : 'help-block',
									focusInvalid : false,
									ignore : "",
									rules : {
										accountName : {
											required : true,
											email : true,
											remote : {// 更新时不验证
												param : {
													url : sys.rootPath
															+ '/user/withoutAuth/validateAccountName.html',
													cache : false
												},
												depends : function() {
													return typeof ($("#userId")
															.val()) == "undefined";
												}
											}
										},
										password : {
											required : true,
											minlength : 6
										},
										repassword : {
											required : true,
											minlength : 6,
											equalTo : "#password"
										},
										userName : {
											required : true
										},
										"role.id" : {
											required : true
										}
									},
									messages : {
										accountName : {
											required : "请填写邮箱",
											email : "请填写正确的邮箱",
											remote : "该邮箱已注册,请使用其他邮箱"
										},
										password : {
											required : "请填写密码",
											minlength : "密码长度不能少于6个字符"
										},
										repassword : {
											required : "请再次填写密码",
											minlength : "密码长度不能少于6个字符",
											equalTo : "两次填写密码不一致，请重新填写"
										},
										userName : "请填写真实姓名",
										"role.id" : "请选择角色"
									},
									highlight : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-info')
												.addClass('has-error');
									},
									success : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-error')
												.addClass('has-success');
										$(e).remove();
									},
									errorPlacement : function(error, element) {
										if (element.is('input[type=checkbox]')
												|| element
														.is('input[type=radio]')) {
											var controls = element
													.closest('div[class*="col-"]');
											if (controls
													.find(':checkbox,:radio').length > 1)
												controls.append(error);
											else
												error.insertAfter(element
														.nextAll('.lbl:eq(0)')
														.eq(0));
										} else if (element.is('.select2')) {
											error
													.insertAfter(element
															.siblings('[class*="select2-container"]:eq(0)'));
										} else if (element.is('.chosen-select')) {
											error
													.insertAfter(element
															.siblings('[class*="chosen-container"]:eq(0)'));
										} else
											error.insertAfter(element.parent());
									},
									submitHandler : function(form) {
										var userId = $("#userId").val();
										var url = "";
										if (userId != undefined) {
											url = '/user/edit.html';
										} else {
											url = '/user/add.html';
										}
										webside.common.commit('userForm', url,
												'/user/listUI.html');
									}
								});
			},
			validateUserPasswordForm : function() {
				$('#userPassword').validate(
						{
							errorElement : 'div',
							errorClass : 'help-block',
							focusInvalid : false,
							ignore : "",
							rules : {
								password : {
									required : true,
									minlength : 6
								},
								repassword : {
									required : true,
									minlength : 6,
									equalTo : "#password"
								}
							},
							messages : {
								password : {
									required : "请填写密码",
									minlength : "密码长度不能少于6个字符"
								},
								repassword : {
									required : "请再次填写密码",
									minlength : "密码长度不能少于6个字符",
									equalTo : "两次填写密码不一致，请重新填写"
								}
							},
							highlight : function(e) {
								$(e).closest('.form-group').removeClass(
										'has-info').addClass('has-error');
							},
							success : function(e) {
								$(e).closest('.form-group').removeClass(
										'has-error').addClass('has-success');
								$(e).remove();
							},
							errorPlacement : function(error, element) {
								error.insertAfter(element.parent());
							},
							submitHandler : function(form) {
								webside.common.commit('userInfo',
										'/user/password.html', '/logout.html');
							},
							invalidHandler : function(form) {
							}
						});
			}
		},
		userInfo : {
			initButton : function() {
				$("#btnEdit").click(function() {
					// 按钮切换
					$(this).hide();
					$("#btnAdd").show();
					// 表单切换
					$("#lableDiv").hide();
					$("#formDiv").show();
				});
			},
			initBirthday : function() {
				$("#birthday").datepicker({
					format : 'yyyy-mm-dd',
					autoclose : true,
					language : 'zh-CN',
					todayHighlight : true,
					clearBtn : true,
					immediateUpdates : true,
					clearDate : function() {
						$("#birthday").val('').datepicker('update');
					}
				});
			},
			validateUserInfoForm : function() {
				jQuery.validator.addMethod("phone", function(value, element) {
					return this.optional(element)
							|| /^1[3|4|5|7|8]\d{9}$/.test(value);
				}, "请输入11位手机号码");

				$('#userInfoForm')
						.validate(
								{
									errorElement : 'div',
									errorClass : 'help-block',
									focusInvalid : false,
									ignore : "",
									rules : {
										userName : {
											required : true
										},
										"userInfo.sex" : {
											required : true
										},
										"userInfo.birthday" : {
											required : true
										},
										"userInfo.telephone" : {
											required : true,
											phone : 'required'
										},
										"userInfo.address" : {
											required : true
										}
									},
									messages : {
										userName : "请填写真实姓名",
										"userInfo.sex" : "请选择性别",
										"userInfo.birthday" : "请填写出生日期",
										"userInfo.telephone" : {
											required : "请填写手机号码",
											phone : "请填写11位手机号码"
										},
										"userInfo.address" : "请填写联系地址"
									},
									highlight : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-info')
												.addClass('has-error');
									},
									success : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-error')
												.addClass('has-success');
										$(e).remove();
									},
									errorPlacement : function(error, element) {
										if (element.is('input[type=checkbox]')
												|| element
														.is('input[type=radio]')) {
											var controls = element
													.closest('div[class*="col-"]');
											if (controls
													.find(':checkbox,:radio').length > 1)
												controls.append(error);
											else
												error.insertAfter(element
														.nextAll('.lbl:eq(0)')
														.eq(0));
										} else if (element.is('.select2')) {
											error
													.insertAfter(element
															.siblings('[class*="select2-container"]:eq(0)'));
										} else if (element.is('.chosen-select')) {
											error
													.insertAfter(element
															.siblings('[class*="chosen-container"]:eq(0)'));
										} else
											error.insertAfter(element.parent());
									},
									submitHandler : function(form) {
										webside.common.commit('userInfoForm',
												'/user/edit.html',
												'/user/infoUI.html?id='
														+ $("#userInfoId")
																.val());
									}
								});
			}
		},
		bvideo : {
			BvideoForm : function() {
				$('#bvideoForm')
						.validate(
								{
									errorElement : 'div',
									errorClass : 'help-block',
									focusInvalid : false,
									ignore : "",
									rules : {
										title : {
											required : true
										},
										description : {
											required : true
										},
										summary : {
											required : true
										},
										setNum : {
											required : true
										},

										resourceId : {
											required : true
										}
									},
									messages : {
										title : "请填写视频标题",
										description : "请填写视频描述",
										summary : "请填写视频简介",
										setNum : "请填写集数",
										resourceId : "请选择视频资源"

									},
									highlight : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-info')
												.addClass('has-error');
									},
									success : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-error')
												.addClass('has-success');
										$(e).remove();
									},
									errorPlacement : function(error, element) {
										if (element.is('input[type=checkbox]')
												|| element
														.is('input[type=radio]')) {
											var controls = element
													.closest('div[class*="col-"]');
											if (controls
													.find(':checkbox,:radio').length > 1)
												controls.append(error);
											else
												error.insertAfter(element
														.nextAll('.lbl:eq(0)')
														.eq(0));

										} else
											error.insertAfter(element.parent());
									},
									submitHandler : function(form) {
										var id = $("#bVideoId").val();
										var url = "";
										if (id != undefined && id != "") {
											url = '/bvideo/edit.html';
										} else {
											url = '/bvideo/add.html';
										}
										webside.common.commit('bvideoForm',
												url,
												'/bvideo/listUI.html?seriesId='
														+ $("#seriesId").val());
									},

								});
			},
			initResource : function() {
				$("#resourceName").bind('click', function(event) {
					var resourceLayer = layer.open({
						type : 2,
						scrollbar : false,
						content : sys.rootPath + '/bvideo/resources.html',
						area : [ '800px', '600px' ],
						maxmin : true,
						shift : 4,
						title : '选择资源'
					});
					// 弹出即全屏
					// layer.open(resourceLayer);
				});
				$("#resourceShow").bind('click', function(event) {
					$("#resourceId").val('');
					$("#resourceName").val('');
					$(this).removeClass();
				});
				$('[data-rel=tooltip]').tooltip();
			},
		},
		diction : {
			DictionForm : function() {
				$('#dictionForm')
						.validate(
								{
									errorElement : 'div',
									errorClass : 'help-block',
									focusInvalid : false,
									ignore : "",
									rules : {
										pName : {
											required : true
										},
										name : {
											required : true
										},
										code : {
											required : true
										},
										sort : {
											required : true
										}
									},
									messages : {
										pName : "请选择所属分类",
										name : "请填写类型名称",
										code : "请填写英文名",
										sort : "请填写排序"
									},
									highlight : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-info')
												.addClass('has-error');
									},
									success : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-error')
												.addClass('has-success');
										$(e).remove();
									},
									errorPlacement : function(error, element) {
										if (element.is('input[type=checkbox]')
												|| element
														.is('input[type=radio]')) {
											var controls = element
													.closest('div[class*="col-"]');
											if (controls
													.find(':checkbox,:radio').length > 1)
												controls.append(error);
											else
												error.insertAfter(element
														.nextAll('.lbl:eq(0)')
														.eq(0));

										} else
											error.insertAfter(element.parent());
									},

									submitHandler : function(form) {
										var id = $("#id").val();
										var url = "";
										if (id != undefined) {
											url = '/diction/edit.html';
										} else {
											url = '/diction/add.html';
										}
										webside.common.commit('dictionForm',
												url, '/diction/listUI.html');
									}
								});
			}

		},
		serieskind : {
			SeriesKindForm : function() {
				$('#serieskindForm')
						.validate(
								{
									errorElement : 'div',
									errorClass : 'help-block',
									focusInvalid : false,
									ignore : "",
									rules : {
										pName : {
											required : true
										},
										name : {
											required : true
										},
										code : {
											required : true
										},
										sort : {
											required : true
										}
									},
									messages : {
										pName : "请选择所属分类",
										name : "请填写类型名称",
										code : "请填写英文名",
										sort : "请填写排序"
									},
									highlight : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-info')
												.addClass('has-error');
									},
									success : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-error')
												.addClass('has-success');
										$(e).remove();
									},
									errorPlacement : function(error, element) {
										if (element.is('input[type=checkbox]')
												|| element
														.is('input[type=radio]')) {
											var controls = element
													.closest('div[class*="col-"]');
											if (controls
													.find(':checkbox,:radio').length > 1)
												controls.append(error);
											else
												error.insertAfter(element
														.nextAll('.lbl:eq(0)')
														.eq(0));

										} else
											error.insertAfter(element.parent());
									},

									submitHandler : function(form) {
										var id = $("#id").val();
										var url = "";
										if (id != undefined) {
											url = '/serieskind/edit.html';
										} else {
											url = '/serieskind/add.html';
										}
										webside.common.commit('serieskindForm',
												url, '/serieskind/listUI.html');
									}
								});
			}

		},
		spread : {
			spreadForm : function() {
				$('#spreadForm')
						.validate(
								{
									errorElement : 'div',
									errorClass : 'help-block',
									focusInvalid : false,
									ignore : "",
									rules : {
										pName : {
											required : true
										},
										name : {
											required : true
										},
										code : {
											required : true
										},
										sort : {
											required : true
										}
									},
									messages : {
										name : "请填写渠道名称",
										code : "请填写渠道标识"
									},
									highlight : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-info')
												.addClass('has-error');
									},
									success : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-error')
												.addClass('has-success');
										$(e).remove();
									},
									errorPlacement : function(error, element) {
										if (element.is('input[type=checkbox]')
												|| element
														.is('input[type=radio]')) {
											var controls = element
													.closest('div[class*="col-"]');
											if (controls
													.find(':checkbox,:radio').length > 1)
												controls.append(error);
											else
												error.insertAfter(element
														.nextAll('.lbl:eq(0)')
														.eq(0));

										} else
											error.insertAfter(element.parent());
									},

									submitHandler : function(form) {
										var id = $("#id").val();
										var url = "";
										if (id != undefined) {
											url = '/spreadsupporter/edit.html';
										} else {
											url = '/spreadsupporter/add.html';
										}
										webside.common.commit('spreadForm',
												url,
												'/spreadsupporter/listUI.html');
									}
								});
			}

		},
		subject : {
			subjectForm : function() {
				$('#subjectForm')
						.validate(
								{
									errorElement : 'div',
									errorClass : 'help-block',
									focusInvalid : false,
									ignore : "",
									rules : {
										subjectName : {
											required : true
										},
										subjectSummary : {
											required : true
										},
										subjectTemplateCode:{
											required : true
										}
									},
									messages : {
										subjectName : "请填写专题名称",
										subjectSummary : "请填写专题标识",
										subjectTemplateCode:"前选择专题模板"
									},
									highlight : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-info')
												.addClass('has-error');
									},
									success : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-error')
												.addClass('has-success');
										$(e).remove();
									},
									errorPlacement : function(error, element) {
										if (element.is('input[type=checkbox]')
												|| element
														.is('input[type=radio]')) {
											var controls = element
													.closest('div[class*="col-"]');
											if (controls
													.find(':checkbox,:radio').length > 1)
												controls.append(error);
											else
												error.insertAfter(element
														.nextAll('.lbl:eq(0)')
														.eq(0));

										} else
											error.insertAfter(element.parent());
									},

									submitHandler : function(form) {
										var id = $("#id").val();
										var url = "";
										if (id != undefined) {
											url = '/subject/edit.html';
										} else {
											url = '/subject/add.html';
										}
										webside.common.commit('subjectForm',
												url,
												'/subject/listUI.html');
									}
								});
			},
			initResource : function() {
				$("#resourceName").bind(
						'click',
						function(event) {
							var subjectId = 0;
							subjectId =subjectId+$("#adsubjectId").val();	
							
							var resourceLayer = layer.open({
								type : 2,
								scrollbar : false,
								content : sys.rootPath
										+ '/subject/SeriesResources.html?subjectId='
										+ subjectId,
								area: ['800px', '600px'], //宽高
								maxmin : true,
								shift : 4,
								title : '选择资源'
							});
							// 弹出即全屏
							/* layer.open(resourceLayer);*/
						});
				$("#SeriesResourceShow").bind('click', function(event) {
					$("#resourceId").val('');
					$("#resourceName").val('');
					$(this).removeClass();
				});
				$('[data-rel=tooltip]').tooltip();
			}

		},
		retype : {
			retypeForm : function() {
				$('#retypeForm')
						.validate(
								{
									errorElement : 'div',
									errorClass : 'help-block',
									focusInvalid : false,
									ignore : "",
									rules : {
										
										source : {
											required : true
										},
										sourceChannelCode:{
											required : true
										},
										sourceTypeName: {
											required : true
										}
									},
									messages : {
										source : "请填写来源名称",
										sourceChannelCode : "请填写资源类型编码",
										sourceTypeName:"请填写资源类型名称"
									},
									highlight : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-info')
												.addClass('has-error');
									},
									success : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-error')
												.addClass('has-success');
										$(e).remove();
									},
									errorPlacement : function(error, element) {
										if (element.is('input[type=checkbox]')
												|| element
														.is('input[type=radio]')) {
											var controls = element
													.closest('div[class*="col-"]');
											if (controls
													.find(':checkbox,:radio').length > 1)
												controls.append(error);
											else
												error.insertAfter(element
														.nextAll('.lbl:eq(0)')
														.eq(0));

										} else
											error.insertAfter(element.parent());
									},

									submitHandler : function(form) {
										var id = $("#id").val();
										var url = "";
										if (id != undefined) {
											url = '/retype/edit.html';
										} else {
											url = '/retype/add.html';
										}
										webside.common.commit('retypeForm',
												url,
												'/retype/listUI.html');
									}
								});
			}
		},
		sensitivewords : {
			sensitivewordsForm : function() {
				$('#sensitivewordsForm')
						.validate(
								{
									errorElement : 'div',
									errorClass : 'help-block',
									focusInvalid : false,
									ignore : "",
									rules : {
										textContent : {
											required : true
										}
									},
									messages : {
										
										textContent : "请填写敏感词"
									},
									highlight : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-info')
												.addClass('has-error');
									},
									success : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-error')
												.addClass('has-success');
										$(e).remove();
									},
									errorPlacement : function(error, element) {
										if (element.is('input[type=checkbox]')
												|| element
														.is('input[type=radio]')) {
											var controls = element
													.closest('div[class*="col-"]');
											if (controls
													.find(':checkbox,:radio').length > 1)
												controls.append(error);
											else
												error.insertAfter(element
														.nextAll('.lbl:eq(0)')
														.eq(0));

										} else
											error.insertAfter(element.parent());
									},

									submitHandler : function(form) {
										var id = $("#id").val();
										var url = "";
										if (id != undefined) {
											url = '/sensitiveword/edit.html';
										} else {
											url = '/sensitiveword/add.html';
										}
										webside.common.commit('sensitivewordsForm',
												url,
												'/sensitiveword/listUI.html');
									}
								});
			}

		},

		adposition : {
			AdpositionForm : function() {
				$('#adpositionForm')
						.validate(
								{
									errorElement : 'div',
									errorClass : 'help-block',
									focusInvalid : false,
									ignore : "",
									rules : {
										name : {
											required : true
										},
										code : {
											required : true
										},
										typeName : {
											required : true
										},
										adInterval : {
											required : true
										}
									},
									messages : {
										name : "请填写名称",
										code : "请填编码",
										typeName : "请填写类型",
										adInterval : "请填写频率"
									},
									highlight : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-info')
												.addClass('has-error');
									},
									success : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-error')
												.addClass('has-success');
										$(e).remove();
									},
									errorPlacement : function(error, element) {
										if (element.is('input[type=checkbox]')
												|| element
														.is('input[type=radio]')) {
											var controls = element
													.closest('div[class*="col-"]');
											if (controls
													.find(':checkbox,:radio').length > 1)
												controls.append(error);
											else
												error.insertAfter(element
														.nextAll('.lbl:eq(0)')
														.eq(0));

										} else
											error.insertAfter(element.parent());
									},

									submitHandler : function(form) {
										var id = $("#id").val();
										var url = "";
										if (id != undefined) {
											url = '/adposition/edit.html';
										} else {
											url = '/adposition/add.html';
										}
										webside.common.commit('adpositionForm',
												url, '/adposition/listUI.html');
									}
								});
			}

		},
		adarrange : {
			AdarrangeForm : function() {
				$('#adarrangeForm')
						.validate(
								{
									errorElement : 'div',
									errorClass : 'help-block',
									focusInvalid : false,
									ignore : "",
									rules : {
										pName : {
											required : true
										},
										name : {
											required : true
										},
										code : {
											required : true
										},
										sort : {
											required : true
										}
									},
									messages : {
										pName : "请选择所属分类",
										name : "请填写类型名称",
										code : "请填写英文名",
										sort : "请填写排序"
									},
									highlight : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-info')
												.addClass('has-error');
									},
									success : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-error')
												.addClass('has-success');
										$(e).remove();
									},
									errorPlacement : function(error, element) {
										if (element.is('input[type=checkbox]')
												|| element
														.is('input[type=radio]')) {
											var controls = element
													.closest('div[class*="col-"]');
											if (controls
													.find(':checkbox,:radio').length > 1)
												controls.append(error);
											else
												error.insertAfter(element
														.nextAll('.lbl:eq(0)')
														.eq(0));

										} else
											error.insertAfter(element.parent());
									},

									submitHandler : function(form) {
										var id = $("#id").val();
										var url = "";
										if (id != undefined) {
											url = '/adarrange/edit.html';
										} else {
											url = '/adarrange/add.html';
										}
										webside.common.commit('adarrangeForm',
												url, '/adarrange/listUI.html');
									}
								});
			}

		},
		adrelease : {
			AdreleaseForm : function() {
				$('#adreleaseForm')
						.validate(
								{
									errorElement : 'div',
									errorClass : 'help-block',
									focusInvalid : false,
									ignore : "",
									rules : {
										resourceName : {
											required : true
										},
										adWeight : {
											required : true
										},
										sDate : {
											required : true
										},
										eDate : {
											required : true
										}
									},
									messages : {
										resourceName : "请选择广告资源",
										adWeight : "请填写优先级",
										sDate : "请填写开始时间",
										eDate : "请填写结束时间"
									},
									highlight : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-info')
												.addClass('has-error');
									},
									success : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-error')
												.addClass('has-success');
										$(e).remove();
									},
									errorPlacement : function(error, element) {
										if (element.is('input[type=checkbox]')
												|| element
														.is('input[type=radio]')) {
											var controls = element
													.closest('div[class*="col-"]');
											if (controls
													.find(':checkbox,:radio').length > 1)
												controls.append(error);
											else
												error.insertAfter(element
														.nextAll('.lbl:eq(0)')
														.eq(0));

										} else
											error.insertAfter(element.parent());
									},

									submitHandler : function(form) {
										var id = $("#id").val();
										var url = "";
										if (id != undefined) {
											url = '/adrelease/edit.html';
										} else {
											url = '/adrelease/add.html';
										}
										webside.common.commit('adreleaseForm',
												url, '/adrelease/listUI.html');
									}
								});
			},
			initResource : function() {
				$("#resourceName").bind(
						'click',
						function(event) {
							var code = $("#positionCode").val();
							var resourceLayer = layer.open({
								type : 2,
								scrollbar : false,
								content : sys.rootPath
										+ '/adrelease/resources.html?code='
										+ code,
								area : [ '800px', '600px' ],
								maxmin : true,
								shift : 4,
								title : '选择资源'
							});
							// 弹出即全屏
							// layer.open(resourceLayer);
						});
				$("#resourceShow").bind('click', function(event) {
					$("#resourceId").val('');
					$("#resourceName").val('');
					$(this).removeClass();
				});
				$('[data-rel=tooltip]').tooltip();
			},

		},
		seo : {
			SeoForm : function() {
				$('#seoForm')
						.validate(
								{
									errorElement : 'div',
									errorClass : 'help-block',
									focusInvalid : false,
									ignore : "",
									rules : {

									},
									messages : {

									},
									highlight : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-info')
												.addClass('has-error');
									},
									success : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-error')
												.addClass('has-success');
										$(e).remove();
									},
									errorPlacement : function(error, element) {
										if (element.is('input[type=checkbox]')
												|| element
														.is('input[type=radio]')) {
											var controls = element
													.closest('div[class*="col-"]');
											if (controls
													.find(':checkbox,:radio').length > 1)
												controls.append(error);
											else
												error.insertAfter(element
														.nextAll('.lbl:eq(0)')
														.eq(0));

										} else
											error.insertAfter(element.parent());
									},

									submitHandler : function(form) {
										var id = $("#id").val();
										var url = "";
										if (id != undefined) {
											url = '/seo/edit.html';
										} else {
											url = '/seo/add.html';
										}
										webside.common.commit('seoForm', url,
												'/seo/listUI.html');
									}
								});
			}

		},
		area : {
			AreaForm : function() {
				$('#areaForm')
						.validate(
								{
									errorElement : 'div',
									errorClass : 'help-block',
									focusInvalid : false,
									ignore : "",
									rules : {
										name :{
											required : true
										},
										code : {
											required : true
										},
										sort : {
											required : true
										}
									},
									messages : {
										name : "请填写类型名称",
										code : "请填写年份",
										sort : "请填写排序"
									},
									highlight : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-info')
												.addClass('has-error');
									},
									success : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-error')
												.addClass('has-success');
										$(e).remove();
									},
									errorPlacement : function(error, element) {
										if (element.is('input[type=checkbox]')
												|| element
														.is('input[type=radio]')) {
											var controls = element
													.closest('div[class*="col-"]');
											if (controls
													.find(':checkbox,:radio').length > 1)
												controls.append(error);
											else
												error.insertAfter(element
														.nextAll('.lbl:eq(0)')
														.eq(0));

										} else
											error.insertAfter(element.parent());
									},

									submitHandler : function(form) {
										var id = $("#id").val();
										var url = "";
										if (id != undefined) {
											url = '/area/edit.html';
										} else {
											url = '/area/add.html';
										}
										webside.common.commit('areaForm', url,
												'/area/listUI.html');

									}
								});
			}

		},
		year : {
			YearForm : function() {
				$('#yearForm')
						.validate(
								{
									errorElement : 'div',
									errorClass : 'help-block',
									focusInvalid : false,
									ignore : "",
									rules : {
										pName : {
											required : true
										},
										name : {
											required : true
										},
										code : {
											required : true
										},
										sort : {
											required : true
										}
									},
									messages : {
										code : "请填写年份",
										sort : "请填写排序"
									},
									highlight : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-info')
												.addClass('has-error');
									},
									success : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-error')
												.addClass('has-success');
										$(e).remove();
									},
									errorPlacement : function(error, element) {
										if (element.is('input[type=checkbox]')
												|| element
														.is('input[type=radio]')) {
											var controls = element
													.closest('div[class*="col-"]');
											if (controls
													.find(':checkbox,:radio').length > 1)
												controls.append(error);
											else
												error.insertAfter(element
														.nextAll('.lbl:eq(0)')
														.eq(0));

										} else
											error.insertAfter(element.parent());
									},

									submitHandler : function(form) {
										var id = $("#id").val();
										var url = "";
										if (id != undefined) {
											url = '/year/edit.html';
										} else {
											url = '/year/add.html';
										}
										webside.common.commit('yearForm', url,
												'/year/listUI.html');
									}
								});
			}

		},
		dictionary : {
			DictionaryForm : function() {
				$('#dictionarysForm')
						.validate(
								{
									errorElement : 'div',
									errorClass : 'help-block',
									focusInvalid : false,
									ignore : "",
									rules : {
										type : {
											required : true
										},
										code : {
											required : true
										},
										name : {
											required : true
										}
									},
									messages : {
										type :"请填写字典类型",
										code :"请填写字典编码",
										name :"请填写字典名称"
									},
									highlight : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-info')
												.addClass('has-error');
									},
									success : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-error')
												.addClass('has-success');
										$(e).remove();
									},
									errorPlacement : function(error, element) {
										if (element.is('input[type=checkbox]')
												|| element
														.is('input[type=radio]')) {
											var controls = element
													.closest('div[class*="col-"]');
											if (controls
													.find(':checkbox,:radio').length > 1)
												controls.append(error);
											else
												error.insertAfter(element
														.nextAll('.lbl:eq(0)')
														.eq(0));

										} else
											error.insertAfter(element.parent());
									},

									submitHandler : function(form) {
										var id = $("#id").val();
										var url = "";
										if (id != undefined) {
											url = '/dictionary/edit.html';
										} else {
											url = '/dictionary/add.html';
										}
										webside.common.commit(
												'dictionarysForm', url,
												'/dictionary/listUI.html');
									}
								});
			}

		},
		role : {
			validateRoleForm : function() {
				$('#roleForm')
						.validate(
								{
									errorElement : 'div',
									errorClass : 'help-block',
									focusInvalid : false,
									ignore : "",
									rules : {
										name : {
											required : true,
											remote : {
												param : {
													url : sys.rootPath
															+ '/role/withoutAuth/validateRoleName.html',
													cache : false
												}
											}
										},
										key : {
											required : true
										}
									},
									messages : {
										name : {
											required : "请填写角色名称",
											remote : "该角色已存在"
										},
										key : "请填写角色标识"
									},
									highlight : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-info')
												.addClass('has-error');
									},
									success : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-error')
												.addClass('has-success');
										$(e).remove();
									},
									errorPlacement : function(error, element) {
										error.insertAfter(element.parent());
									},
									submitHandler : function(form) {
										var roleId = $("#roleId").val();
										var url = "";
										if (roleId != undefined) {
											url = '/role/edit.html';
										} else {
											url = '/role/add.html';
										}
										webside.common.commit('roleForm', url,
												'/role/listUI.html');
									}
								});
			}
		},
		localad : {
			validateLocaladForm : function() {
				$('#localadForm')
						.validate(
								{
									errorElement : 'div',
									errorClass : 'help-block',
									focusInvalid : false,
									ignore : "",
									rules : {

										title : {
											required : true
										},
										owner : {
											required : true
										},
										sDate : {
											required : true
										},
										eDate : {
											required : true
										},
										resourceType : {
											required : true
										},
										typeName : {
											required : true
										},
										linkUrl : {
											required : true
										}

									},

									messages : {
										/*
										 * imgUrl : { required : "请上传图片", remote :
										 * "该图片已存在" },
										 */
										title : "请填写标题",
										owner : "请填写广告商",
										sDate : "请填写开始时间",
										eDate : "请填写截止时间",
										resourceType : "请选择资源类型",
										typeName : "请选择类型",
										linkUrl : "请填入链接"
									},
									highlight : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-info')
												.addClass('has-error');
									},
									success : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-error')
												.addClass('has-success');
										$(e).remove();
									},
									errorPlacement : function(error, element) {
										if (element.is('input[type=checkbox]')
												|| element
														.is('input[type=radio]')) {
											var controls = element
													.closest('div[class*="col-"]');
											if (controls
													.find(':checkbox,:radio').length > 1)
												controls.append(error);
											else
												error.insertAfter(element
														.nextAll('.lbl:eq(0)')
														.eq(0));

										} else
											error.insertAfter(element.parent());
									},

									submitHandler : function(form) {
										var id = $("#id").val();
										var url = "";
										if (id != undefined) {
											url = '/localad/edit.html';
										} else {
											url = '/localad/add.html';
										}
										webside.common.commit('localadForm',
												url, '/localad/listUI.html');
									}
								});
			},
			initResource : function() {
				$("#resourceName").bind('click', function(event) {
					var resourceLayer = layer.open({
						type : 2,
						scrollbar : false,
						content : sys.rootPath + '/localad/resources.html',
						area : [ '800px', '600px' ],
						maxmin : true,
						shift : 4,
						title : '选择资源'
					});
					// 弹出即全屏
					// layer.open(resourceLayer);
				});
				$("#resourceShow").bind('click', function(event) {
					$("#resourceId").val('');
					$("#resourceName").val('');
					$(this).removeClass();
				});
				$('[data-rel=tooltip]').tooltip();
			},

		},
		banner : {
			BannerForm : function() {
				$('#bannerForm')
						.validate(
								{
									errorElement : 'div',
									errorClass : 'help-block',
									focusInvalid : false,
									ignore : "",
									rules : {
										/*
										 * imgUrl : { required : true, remote : {
										 * param : { url : sys.rootPath +
										 * '/banner/withoutAuth/validateRoleName.html',
										 * cache : false } } },
										 */
										title: {
											required : true
										},
										summary: {
											required : true
										},
										channel: {
											required : true
										},
										linkUrl: {
											required : true
										},
										sort : {
											required : true
										}

									},
									messages : {
										/*
										 * imgUrl : { required : "请上传图片", remote :
										 * "该图片已存在" },
										 */
										title:"请填写标题",
										summary:"请填写描述",
										channel:"请填写频道",
										linkUrl:"请填写链接",
										sort : "请填写排序"

									},
									highlight : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-info')
												.addClass('has-error');
									},
									success : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-error')
												.addClass('has-success');
										$(e).remove();
									},
									errorPlacement : function(error, element) {
										if (element.is('input[type=checkbox]')
												|| element
														.is('input[type=radio]')) {
											var controls = element
													.closest('div[class*="col-"]');
											if (controls
													.find(':checkbox,:radio').length > 1)
												controls.append(error);
											else
												error.insertAfter(element
														.nextAll('.lbl:eq(0)')
														.eq(0));

										} else
											error.insertAfter(element.parent());
									},

									submitHandler : function(form) {
										var id = $("#id").val();
										var url = "";
										if (id != undefined) {
											url = '/banner/edit.html';
										} else {
											url = '/banner/add.html';
										}
										webside.common.commit('bannerForm',
												url, '/banner/listUI.html');
									}
								});
			}

		},
		partner : {

			PartnerForm : function() {
				$('#partnerForm')
						.validate(
								{
									errorElement : 'div',
									errorClass : 'help-block',
									focusInvalid : false,
									ignore : "",
									rules : {
										linkUrl : {
											required : true
										},
										sort : {
											required : true
										}

									},
									messages : {
										linkUrl :"请填写链接地址",
										sort : "请填写排序"

									},
									highlight : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-info')
												.addClass('has-error');
									},
									success : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-error')
												.addClass('has-success');
										$(e).remove();
									},
									errorPlacement : function(error, element) {
										if (element.is('input[type=checkbox]')
												|| element
														.is('input[type=radio]')) {
											var controls = element
													.closest('div[class*="col-"]');
											if (controls
													.find(':checkbox,:radio').length > 1)
												controls.append(error);
											else
												error.insertAfter(element
														.nextAll('.lbl:eq(0)')
														.eq(0));

										} else
											error.insertAfter(element.parent());
									},

									submitHandler : function(form) {
										var id = $("#id").val();
										var url = "";
										if (id != undefined) {
											url = '/partner/edit.html';
										} else {
											url = '/partner/add.html';
										}
										webside.common.commit('partnerForm',
												url, '/partner/listUI.html');
									}
								});
			}

		},

		series : {
			validateSeriesForm : function() {
				$('#seriesForm')
						.validate(
								{
									errorElement : 'div',
									errorClass : 'help-block',
									focusInvalid : false,
									ignore : "",
									rules : {
										name : {
											required : true
										},
										summary : {
											required : true
										},
										channel : {
											required : true
										},
										kind : {
											required : true
										},
										type : {
											required : true
										},
										language : {
											required : true
										},
										year : {
											required : true
										},
										area : {
											required : true
										},
										/*
										 * poster : { required : true }, cover : {
										 * required : true },
										 */
										director : {
											required : true
										},
										actor : {
											required : true
										},
										setSum : {
											required : true
										},
										recommendLevel : {
											required : true
										},
										clarity : {
												required : true
											},
									},
									messages : {
										name : "请填写剧集名称",
										summary : "请填写简介",
										channel : "请选择频道",
										kind : "请选择频道分类",
										type : "请选择剧情类型",
										language : "请选择语言",
										year : "请选择年份",
										area : "请选择地区",
										/*
										 * poster : "请上传海报", cover : "请上传封面",
										 */
										director : "请填写导演",
										actor : "请填写主演",
										setSum : "请填写总集数",
										recommendLevel:"请选择推荐等级",
										clarity:"请选择清晰度",
									},
									highlight : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-info')
												.addClass('has-error');
									},
									success : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-error')
												.addClass('has-success');
										$(e).remove();
									},
									errorPlacement : function(error, element) {
										if (element.is('input[type=checkbox]')
												|| element
														.is('input[type=radio]')) {
											var controls = element
													.closest('div[class*="col-"]');
											if (controls
													.find(':checkbox,:radio').length > 1)
												controls.append(error);
											else
												error.insertAfter(element
														.nextAll('.lbl:eq(0)')
														.eq(0));

										} else
											error.insertAfter(element.parent());
									},

									submitHandler : function(form) {
										var id = $("#id").val();
										var url = "";
										if (id != undefined) {
											url = '/series/edit.html';
										} else {
											url = '/series/add.html';
										}
										webside.common.commit('seriesForm',
												url, '/series/listUI.html');
									}
								});
			}

		},
		dealseries : {
			validateSeriesForm : function() {
				$('#seriesForm')
						.validate(
								{
									errorElement : 'div',
									errorClass : 'help-block',
									focusInvalid : false,
									ignore : "",
									rules : {
										name : {
											required : true
										},
										summary : {
											required : true
										},
										channel : {
											required : true
										},
										kind : {
											required : true
										},
										type : {
											required : true
										},
										language : {
											required : true
										},
										year : {
											required : true
										},
										area : {
											required : true
										},
										/*
										 * poster : { required : true }, cover : {
										 * required : true },
										 */
										director : {
											required : true
										},
										actor : {
											required : true
										},
										setSum : {
											required : true
										},
									},
									messages : {
										name : "请填写剧集名称",
										summary : "请填写简介",
										channel : "请选择频道",
										kind : "请选择频道分类",
										type : "请选择剧情类型",
										language : "请选择语言",
										year : "请选择年份",
										area : "请选择地区",
										/*
										 * poster : "请上传海报", cover : "请上传封面",
										 */
										director : "请填写导演",
										actor : "请填写主演",
										setSum : "请填写总集数"
									},
									highlight : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-info')
												.addClass('has-error');
									},
									success : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-error')
												.addClass('has-success');
										$(e).remove();
									},
									errorPlacement : function(error, element) {
										if (element.is('input[type=checkbox]')
												|| element
														.is('input[type=radio]')) {
											var controls = element
													.closest('div[class*="col-"]');
											if (controls
													.find(':checkbox,:radio').length > 1)
												controls.append(error);
											else
												error.insertAfter(element
														.nextAll('.lbl:eq(0)')
														.eq(0));

										} else
											error.insertAfter(element.parent());
									},

									submitHandler : function(form) {
										var id = $("#id").val();
										var url = "";
										if (id != undefined) {
											url = '/series/edit.html';
										} else {
											url = '/series/add.html';
										}
										webside.common.commit('seriesForm',
												url, '/dealseries/listUI.html');
									}
								});
			}

		},

		videoresource : {
			ResourceForm : function() {
				$('#videoResourceForm')
						.validate(
								{
									errorElement : 'div',
									errorClass : 'help-block',
									focusInvalid : false,
									ignore : "",
									rules : {
										name : {
											required : true
										},
										url : {
											required : true
										},

										size : {
											required : true
										},
										h360pUrl : {
											required : true
										},

										timeSpan : {
											required : true
										},
									},
									messages : {
										name : "请填写资源名称",
										url : "请填写源地址",
										size : "请填写大小",
										kind : "请填写时长",
										h360pUrl : "请填写地址"
									},
									highlight : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-info')
												.addClass('has-error');
									},
									success : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-error')
												.addClass('has-success');
										$(e).remove();
									},
									errorPlacement : function(error, element) {
										if (element.is('input[type=checkbox]')
												|| element
														.is('input[type=radio]')) {
											var controls = element
													.closest('div[class*="col-"]');
											if (controls
													.find(':checkbox,:radio').length > 1)
												controls.append(error);
											else
												error.insertAfter(element
														.nextAll('.lbl:eq(0)')
														.eq(0));

										} else
											error.insertAfter(element.parent());
									},

									submitHandler : function(form) {
										var id = $("#id").val();
										var url = "";
										if (id != undefined) {
											url = '/videoresource/edit.html';
										} else {
											url = '/videoresource/add.html';
										}
										webside.common.commit(
												'videoResourceForm', url,
												'/videoresource/listUI.html');
									}
								});
			}

		},

		bvideoweb : {
			bvideowebForm : function() {
				$('#bvideowebForm')
						.validate(
								{
									errorElement : 'div',
									errorClass : 'help-block',
									focusInvalid : false,
									ignore : "",
									rules : {
										title : {
											required : true
										},
										source : {
											required : true
										},
										type : {
											required : true
										},
										detailUrl : {
											required : true
										},
										playUrl : {
											required : true
										}
									},
									messages : {
										title : "请填写预告片标题",
										source : "请填写预告片来源",
										type : "请填写预告片分类",
										detailUrl : "请填写预告片详细页地址",
										playUrl : "请填写预告片播放地址"

									},
									highlight : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-info')
												.addClass('has-error');
									},
									success : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-error')
												.addClass('has-success');
										$(e).remove();
									},
									errorPlacement : function(error, element) {
										if (element.is('input[type=checkbox]')
												|| element
														.is('input[type=radio]')) {
											var controls = element
													.closest('div[class*="col-"]');
											if (controls
													.find(':checkbox,:radio').length > 1)
												controls.append(error);
											else
												error.insertAfter(element
														.nextAll('.lbl:eq(0)')
														.eq(0));

										} else
											error.insertAfter(element.parent());
									},

									submitHandler : function(form) {
										var id = $("#id").val();
										var url = "";
										if (id != undefined) {
											url = '/bvideoweb/edit.html';
										}
										webside.common.commit('bvideowebForm',
												url, '/bvideoweb/listUI.html');
									}
								});
			}

		},

		resource : {
			initSourceType : function() {
				$('#type').select2({
					language : "zh-CN",
					minimumResultsForSearch : Infinity
				});
			},
			initSourceTree : function() {
				$('#parentId').select2({
					placeholder : "请选择上级资源...",
					language : "zh-CN",
					minimumResultsForSearch : Infinity,
					templateResult : webside.form.resource.formatState,
					templateSelection : function(selection) {
						return $.trim(selection.text);
					}
				});
			},
			formatState : function(state) {
				if (!state.id) {
					return state.text;
				}
				var $state = $('<span><i class="fa fa-file-text-o green"></i>&nbsp;&nbsp;'
						+ state.text + '</span>');
				return $state;
			},
			initIcon : function() {
				$("#icon").bind('focus', function(event) {
					var iconLayer = layer.open({
						type : 2,
						scrollbar : false,
						content : sys.rootPath + '/resource/icon.html',
						area : 'auto',
						maxmin : true,
						shift : 4,
						title : '<i class="fa fa-cogs"></i>&nbsp;选择图标'
					});
					// 弹出即全屏
					layer.full(iconLayer);
				});
				$("#iconShow").bind('click', function(event) {
					$("#icon").val('');
					$(this).removeClass();
				});
				$('[data-rel=tooltip]').tooltip();
			},
			initType : function() {
				$("#parentId").change(
						function() {
							var parentId = $.trim($(this).children(
									'option:selected').val());
							if (parentId == null || parentId == '') {
								// $("#iconDiv").show();
								// $("#sourceUrlDiv").hide();
							} else {
								// $("#iconDiv").hide();
								// $("#sourceUrlDiv").show();
							}
						});
			},
			validateResourceForm : function() {
				$('#resourceForm')
						.validate(
								{
									errorElement : 'div',
									errorClass : 'help-block',
									focusInvalid : false,
									ignore : "",
									rules : {
										parentId : {
											required : true
										},
										name : {
											required : true
										},
										sourceKey : {
											required : true
										},
										type : {
											required : true
										},
										sourceUrl : {
											required : function() {
												/*
												 * //仅目录菜单不需要url var parentId =
												 * $.trim($("#parentId").val());
												 * if (parentId == null ||
												 * parentId == "") { return
												 * false; } else { return true; }
												 */
												return false;
											}
										},
										icon : {
											required : function() {
												/*
												 * //仅目录菜单需要icon var parentId =
												 * $.trim($("#parentId").val());
												 * if (parentId == null ||
												 * parentId == "") { return
												 * true; } else { return false; }
												 */
												return false;
											}
										}
									},
									messages : {
										parentId : "请选择上级资源",
										name : "请填写资源名称",
										sourceKey : "请填写资源标识",
										type : "请选择资源类型",
										sourceUrl : "请填写资源URL",
										icon : "请选择菜单图标"
									},
									highlight : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-info')
												.addClass('has-error');
									},
									success : function(e) {
										$(e).closest('.form-group')
												.removeClass('has-error')
												.addClass('has-success');
										$(e).remove();
									},
									errorPlacement : function(error, element) {
										if (element.is('input[type=checkbox]')
												|| element
														.is('input[type=radio]')) {
											var controls = element
													.closest('div[class*="col-"]');
											if (controls
													.find(':checkbox,:radio').length > 1)
												controls.append(error);
											else
												error.insertAfter(element
														.nextAll('.lbl:eq(0)')
														.eq(0));
										} else if (element.is('.select2')) {
											error
													.insertAfter(element
															.siblings('[class*="select2-container"]:eq(0)'));
										} else if (element.is('.chosen-select')) {
											error
													.insertAfter(element
															.siblings('[class*="chosen-container"]:eq(0)'));
										} else
											error.insertAfter(element.parent());
									},
									submitHandler : function(form) {
										var resourceId = $("#resourceId").val();

										var url = "";
										if (resourceId != undefined) {
											url = '/resource/edit.html';
										} else {
											url = '/resource/add.html';
										}
										webside.common.commit('resourceForm',
												url, '/resource/listUI.html');
									}
								});
			},
			authorize : {
				ids : [],
				initResourceTree : function() {
					$('#tree')
							.jstree(
									{
										"core" : {
											'data' : {
												"url" : sys.rootPath
														+ "/resource/resourceTree.html?roleId="
														+ $("#id").val(),
												"dataType" : "json"
											},
											"themes" : {
												"responsive" : true
											},
											"multiple" : true,
											"animation" : 200,
											"dblclick_toggle" : true,
											"expand_selected_onload" : true
										},
										"checkbox" : {
											"keep_selected_style" : true,
											"three_state" : false,
											"cascade" : "up"
										},
										"plugins" : [ "checkbox" ]
									});
				},
				/**
				 * 递归遍历节点，获取该节点的所有父节点
				 * 
				 * @param {Object}
				 *            treeObj jstree对象
				 * @param {Object}
				 *            nodeObj jstree node节点对象
				 */
				getParents : function(treeObj, nodeObj) {
					var parentId = treeObj.get_parent(nodeObj);
					if (parentId != "#") {
						webside.form.resource.authorize.ids.push(parentId);
						webside.form.resource.authorize.getParents(treeObj,
								treeObj.get_node(parentId));
					}
				},
				/**
				 * 提交表单 适用场景：form表单的提交，角色授权提交
				 * 
				 * @param {Object}
				 *            commitUrl 表单提交地址
				 * @param {Object}
				 *            listUrl 表单提交成功后转向的列表页地址
				 */
				commitPerm : function(commitUrl, listUrl) {
					webside.form.resource.authorize.ids = [];
					var tree = $('#tree').jstree();
					// 获取所有选中节点id
					var selectedIds = tree.get_checked();
					// 获取所有选中节点
					var selected = tree.get_checked(true);
					// 遍历节点，获取选中节点的所有父节点
					for (var i = 0; i < selected.length; i++) {
						webside.form.resource.authorize.getParents(tree,
								selected[i]);
					}
					var index;
					$.ajax({
						type : "POST",
						url : sys.rootPath + commitUrl,
						data : {
							"roleId" : $("#id").val(),
							"resourceIds" : _.union(
									webside.form.resource.authorize.ids,
									selectedIds).join(',')
						},
						dataType : "json",
						beforeSend : function() {
							index = layer.load();
						},
						success : function(resultdata) {
							layer.close(index);
							if (resultdata.success) {
								layer.msg(resultdata.message, {
									icon : 1
								});
								webside.common.loadPage(listUrl + '?page='
										+ $("#pageNum").val() + '&rows='
										+ $("#pageSize").val() + '&sidx='
										+ $("#orderByColumn").val() + '&sord='
										+ $("#orderByType").val());
							} else {
								layer.msg(resultdata.message, {
									icon : 5
								});
							}
						},
						error : function(errorMsg) {
							layer.close(index);
							layer.msg('服务器未响应,请稍后再试', {
								icon : 2
							});
						}
					});
				}
			}
		}
	}
};
function back() {
	$(".page-content").load(sys.rootPath + "/welcome.jsp");
	// window.href.location="index.html";
}